<!DOCTYPE html>
<html>
<head>

    <meta charset="UTF-8">
    <title>{if $buy_type==2}{$is_language?'做空申請':'Short for'}{else}{$is_language?'買入申請':'Buy application'}{/if}</title>
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <link rel="stylesheet" href="__MODULE_LIBS__/css/weui.min.css">
    <link rel="stylesheet" href="__MODULE_LIBS__/css/jquery-weui.css">
    <link rel="stylesheet" href="__MODULE_LIBS__/css/demos.css">
    <script src="__MODULE_LIBS__/js/jquery-2.1.4.js"></script>
    <script src="__MODULE_LIBS__/js/fastclick.js"></script>
    <script src="__MODULE_LIBS__/js/jquery-weui.js"></script>
    <style type="text/css">
        * {
            margin: 0;
            padding: 0;
        }

        html {
            width: 100%;
            height: 100%;
            font-size: 20px;
            font-family: "Microsoft YaHei", "宋体", "Segoe UI", "Lucida Grande", Helvetica, Arial, sans-serif, FreeSans, Arimo;
            background: #F3F3F3;
        }

        body {
            margin: 0 auto;
            max-width: 750px;
            height: 100%;
            background: #F7F7F7;
        }

        /*顶部导航栏处的样式*/
        .navbar {
            position: relative;
            width: 100%;
            height: 2rem;
            font-size: 16px;
            color: #fff;
            line-height: 2rem;
            background: #373553;
        }

        .navbar-item {
            position: absolute;
            left: 0;
            top: 0;
            display: block;
            width: 3.2rem;
            height: 2rem;
            font-size: 14px;
            color: #fff;
            text-align: center;
        }

        .navbar-item > img {
            width: 0.8rem;
            height: 0.7rem;
            vertical-align: middle;
        }

        .navbar-center {
            text-align: center;
        }

        /*主体部分的样式*/
        .content {
            width: 100%;
        }

        /*列表样式*/
        .weui-cells {
            font-size: 0.7rem;
        }

        .weui-cell {
            padding: 0.3rem 0.5rem;
        }

        .weui-cell__hd {
            width: 5rem;
            height: 100%;
        }
        .weui-cell__bd{
            font-size: 0.65rem;
        }

        .account {
            margin-top: 0.3rem;
            font-size: 0.6rem;
            color: #999999;
        }

        .price {
            color: #F44444;
        }

        .weui-btn + .weui-btn {
            margin-top: 0.3rem;
        }

        .weui-btn_mini {
            padding: 0 0.6rem;
        }

        .weui-media-box__desc {
            font-size: 0.5rem;
        }

        .refuse {
            background-color: #999999;
        }

        .agree-dlog {
            position: fixed;
            top: 0px;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.4);
            z-index: 10000;
            display: none;
        }

        .dlog {
            position: relative;
            top: 8rem;
            left: 0;
            margin: 0 auto;
            padding: 0.5rem;
            width: 13rem;
            height: auto;
            background: #fff;
            border-radius: 0.4rem;
            z-index: 100000;
        }

        .agree-close {
            position: absolute;
            top: 0rem;
            right: 0rem;
            width: 2rem;
            height: 1.4rem;
            text-align: center;
            line-height: 1.4rem;
            cursor: pointer;
        }

        .agreeForm {
            margin-top: 0.5rem;
            width: 100%;
            font-size: 0.65rem;
        }

        .agreeForm > p {
            display: block;
            width: 100%;
            margin-top: 0.6rem;
            margin-bottom: 0.4rem;
            text-align: center;
        }
        .agreeForm input[type="number"]{
            padding-left: 0.3rem;
            width: 7.4rem;
            border: 0;
            border-bottom: 1px #F44444 solid;
            outline: 0;
        }

        .agreebtn {
            width: 10rem;
            height: 1.5rem;
            color: #FFFFFF;
            background: #F44444;
            border: 0;
            border-radius: 0.2rem;
            outline: 0;
            cursor: pointer;
        }

        .weui-mask {
            z-index: 1000000;
        }

        .weui-dialog {
            z-index: 2000000;
        }

        .pagination > li {
            float: left;
            padding: 2px 6px;
            margin: 0 4px;
            list-style: none;
            color: #fff;
            background: #aaa;
            border-radius: 5px;
        }

        .pagination > li > a {
            color: #fff;
        }

        .pagination > li.active {
            background: #f44444;
        }
        .red {
            color: #e64340;
        }
    </style>
</head>
<body>
<header class="navbar">
    <a href="{:url('goods/index')}" class="navbar-item">
        <img src="__MODULE_LIBS__/img/back.png"/>&nbsp;{$is_language?'返回':'Return'}
    </a>
    <div class="navbar-center">{if $buy_type==2}{$is_language?'做空申請':'Short for'}{else}{$is_language?'買入申請':'Buy application'}{/if}</div>
    <div class="navbar-item1">
        <select name="" id="yy">
            <option value="1" {$is_language?'selected':''}>中文</option>
            <option value="0" {$is_language?'':'selected'}>English</option>
        </select>
    </div>
</header>

<div class="content">
    <!--重复部分开始-->
    {foreach $order_data['data'] as $vo}
    <div class="weui-cells">
        <div class="weui-cell">
            <div class="weui-cell__hd">
                {if $vo.type==4}
                <p class="nickname red">{$is_language?'融资買入':'To apply for funding'}</p>
                {/if}
                <p class="nickname">{$vo.user.nickname}</p>
                <p class="account">{$vo.user.username}</p>
            </div>
            <div class="weui-cell__bd">
                <p class="price">{$is_language?'買入金額':'Buying amount'}:${$vo.money}</p>
                <p class="price">{if !empty($buy_type)&&$buy_type==2}{$is_language?'申請做空數量':'Apply for a short number'}{else}{$is_language?'申請購買數量':'Apply for buy quantity'}{/if}:{$vo.sum}</p>
                <p class="price">{if !empty($buy_type)&&$buy_type==2}{$is_language?'實際做空數量':'Actual short quantity'}{else}{$is_language?'實際購買數量':'Actual purchase quantity'}{/if}:{$vo.actual_sum}</p>
            </div>
            <div class="weui-cell__ft">
                {if $vo.type==4}
                <p class="weui-media-box__desc red">{$is_language?'融資比例':'Financing proportion'}：1:{$vo.capital_pro}</p>
                {/if}
                <p class="weui-media-box__desc">{$vo.create_time|date="Y-m-d H:i:s",###}</p>
                {if $vo.status==0}
                <button class="weui-btn weui-btn_mini weui-btn_warn agree">{$is_language?'同意':'Agree'}</button>
                <button class="weui-btn weui-btn_mini weui-btn_warn refuse">{$is_language?'拒絕':'Refuse'}</button>
                <form action="{:url('buyin_info')}" method="post" class="reform">
                    <input type="hidden" name="id" value="{$vo.id}" class="agreeid">
                    <input type="hidden" name="sum" value="0">
                    <input type="hidden" name="type" value="refuse">
                </form>
                {elseif $vo.status==1}
                {$is_language?'同意':'Agree'}
                {elseif $vo.status==2}
                {$is_language?'拒絕':'Refuse'}
                {elseif $vo.status==4}
                <p class="price" style="color: #999;">{$is_language?'等待配資':'Waiting for money'}</p>
                {elseif $vo.status==5}
                <p class="price" style="color: #999;">{$is_language?'配資失敗':'Financing is rejected'}</p>
                {/if}
            </div>
        </div>
    </div>
    {/foreach}
    <!--重复部分结束-->
    {$page}
</div>
<input type="hidden" name="yuyan" value="<?php echo @$is_language?>" id="yuyan">
<!--同意处的弹出框开始-->
<div class="agree-dlog">
    <div class="dlog">
        <div class="agree-close">X</div>
        <form action="{:url('buyin_info')}" method="post" class="agreeForm">
            <input type="hidden" name="id" value="" id="hidid">
            <input type="hidden" name="type" value="agree" id="hidtype">
            <p style="text-align: left;margin-left: 1.6rem;">
                <label style="vertical-align: top;">{$is_language?'數量':'Number'}：</label>
                <input type="number" class="numInput" name="sum" value="">
            </p>
            <p>
                <input type="submit" class="agreebtn" value="{$is_language?'確認':'Determine'}"/>
            </p>
        </form>
    </div>
</div>
<!--同意处的弹出框开始-->

<script type="text/javascript">
    $(document).on("change",'select#yy',function(){
        var yy = $(this).val();
        console.log(yy)
        var url = "{:url('index/language')}";
        $.post(url,{language:yy},function (res) {
            window.location.reload();
        })
    });
    $(function () {
        FastClick.attach(document.body);

        //同意处的弹出框
        $(".agree").click(function () {
            var hidid = $(this).parents(".weui-cells").find('.agreeid').val();
            $("#hidid").val(hidid);

            $(".agree-dlog").css('display', 'block');
            $('body').css({
                "overflow-x": "hidden",
                "overflow-y": "hidden"
            });

            //阻止默认
            $("body").on("touchmove", function (event) {
                event.preventDefault;
            }, false);

            $.ajax({
                type: "POST",
                url: "{:url('ajax_order')}",
                dataType:"json",
                data:{
                    id:hidid
                },
                success: function(data){
                    $(".numInput").val(data.content.sum);
                }
            });

        });

        $('.agree-close').click(function () {
            $(".agree-dlog").css('display', 'none');
            $('body').css({
                "overflow-x": "auto",
                "overflow-y": "auto"
            });
            //然后点击取消或者确定时再取消body上的绑定
            $("body").off("touchmove");
            $('.numInput').val(1);

        });

        $(".refuse").bind("click", function () {
            var self = $(this);
            var yuyan = $('#yuyan').val();
            if(yuyan==1){
                $.confirm({
                    title: '提示',
                    text: '是否確認拒絕？',
                    onOK: function () {
                        //点击确认
                        self.parents(".weui-cells").find(".reform").submit();
                    },
                    onCancel: function () {
                        //点击取消
                    }
                });
            }else{
                $.confirm({
                    title: 'Prompt',
                    text: 'Confirm rejection?',
                    onOK: function () {
                        //点击确认
                        self.parents(".weui-cells").find(".reform").submit();
                    },
                    onCancel: function () {
                        //点击取消
                    }
                });
            }
        })
    })
</script>
</body>
</html>
